﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Plugins.UserControls
{
    public partial class PresetSelector : UserControl
	{
		#region Dependence Properties

		public static DependencyProperty IsSaveEnabledProperty = DependencyProperty.Register("IsSaveEnabled", typeof(bool), typeof(PresetSelector));

		public bool IsSaveEnabled
		{
			get
			{
				return (bool)base.GetValue(IsSaveEnabledProperty);
			}
			set
			{
				base.SetValue(IsSaveEnabledProperty, value);
			}
		}

		#endregion

		#region Properties

		public new IPresetSelector DataContext
		{
			get
			{
				return (IPresetSelector)base.DataContext;
			}
			set
			{
				if (this.DataContext != value)
				{
					base.DataContext = value;
				}
			}
		}

		#endregion

		#region Public Methods

		public PresetSelector()
        {
            InitializeComponent();
        }

        #endregion

        #region Event Handlers

		private void TextBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
		{
			if (e.Key == Key.Enter && this.DataContext.SaveCommand.CanExecute(null))
			{
				this.DataContext.SaveCommand.Execute(null);
			}
		}

		private void ComboBox_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
			if (this.DataContext.RefreshPresetsCommand.CanExecute(null))
			{
				this.DataContext.RefreshPresetsCommand.Execute(null);
			}
		}

        #endregion

    }
}
